Skip to content

fix(elements): ensure updated provided values are sent to the machine - #3702

Merged
alexcarpenter merged 4 commits into
mainfrom
alexcarpenter/sdki-136-ensure-controlled-inputs-value-is-up-to-date-and-sent-to
Jul 15, 2024
Merged

fix(elements): ensure updated provided values are sent to the machine#3702
alexcarpenter merged 4 commits into
mainfrom
alexcarpenter/sdki-136-ensure-controlled-inputs-value-is-up-to-date-and-sent-to

Conversation

@alexcarpenter

Copy link
Copy Markdown
Member

Description

Fix an issue when the elements input has a controlled value, it was not getting updated when the value changed. Causing stale values to persist.

Renamed the prop to providedValue as its not only used for the initialValue.

Example usage in AIO components rebuild to support the country code being separated from the formatted phone number.

function Example() {
  const [val, setVal] = useState('')
  return (
    <>
      // Hidden elements input
      <Common.Input hidden value={val} />
      <input value={val} onChange={e => setValue(e.target.value}} />
    </>
  )
}

BEFORE

Screen.Recording.2024-07-12.at.10.03.26.AM.mov

AFTER

Screen.Recording.2024-07-12.at.10.02.23.AM.mov

https://linear.app/clerk/issue/SDKI-136/ensure-controlled-inputs-value-is-up-to-date-and-sent-to-machine-on

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-bot Bot commented Jul 12, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0e342a0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/elements Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@alexcarpenter alexcarpenter changed the title ensure updated provided values are sent to the machine fix(elements): ensure updated provided values are sent to the machine Jul 12, 2024

@octoper octoper left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@tmilewski tmilewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@alexcarpenter
alexcarpenter enabled auto-merge (squash) July 15, 2024 14:37
@alexcarpenter
alexcarpenter merged commit 2e6afd1 into main Jul 15, 2024
@alexcarpenter
alexcarpenter deleted the alexcarpenter/sdki-136-ensure-controlled-inputs-value-is-up-to-date-and-sent-to branch July 15, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants